﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TMDT_Nhom1A.BUS;
using TMDT_Nhom1A.DTO;

namespace TMDT_Nhom1A.Customer
{
    public partial class CacDonHangDaMua : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (Session["UserID"].ToString() != "")
                {
                    List<ORDER_B2B> list1 = Customer_BUS.GetBillPaiedBuyOnline(Session["UserID"].ToString());
                    gvbillbuyonline.DataSource = list1;
                    gvbillbuyonline.DataBind();
                    lbcount1.Text = gvbillbuyonline.Rows.Count.ToString();
                    decimal totalprice1 = 0;
                    for (int i = 0; i < list1.Count; i++)
                    {
                        totalprice1 += (decimal)list1[i].TotalPrice;
                    }
                    lbtotalprice1.Text = totalprice1.ToString("###,###,###") + " VND";

                    List<ORDER_COUPON> list2 = Customer_BUS.GetBillPaiedBuyByCompany(Session["UserID"].ToString());
                    gvbillbuybycompany.DataSource = list2;
                    gvbillbuybycompany.DataBind();
                    lbcount2.Text = gvbillbuybycompany.Rows.Count.ToString();
                    decimal totalprice2 = 0;
                    for (int i = 0; i < list2.Count; i++)
                    {
                        totalprice2 += (decimal)list2[i].TotalPrice;
                    }
                    lbtotalprice2.Text = totalprice2.ToString("###,###,###") + " VND";

                }
            }
        }

       
    }
}
